#!/bin/bash
#this script executes a python script for html and rss updating
if [ ! -d "entries" ] || [ ! -d "public_html" ]; then
        echo "You haven't initialized nci system yet... Please use \"./init\" before posting a new entry."
        exit 1
fi

if [ ! -f "nci.conf" ]; then
	echo "Congrats! You deleted your configuration file. Now nci can't work. You are really smart :)"
	echo "To fix this problem, create a file named \"nci.conf\" in this directory, and fill it with the following data:"
	echo "1st line - Your neocities username (without \".neocities.org\" at the end of the string)."
	echo "2nd line - The filename of your blog html file (without \".html\" at the end of the string)."
	echo
	echo "Now try not to delete your configuration file, you dumb."
	exit 1
fi

if [ ! -f "public_html/articles/article_template.html" ]; then
	echo "Well, this is nice. You deleted the article template html file (\"public_html/entries_html/article_template.html\"). Now nci can't work."
	echo "To fix this problem, you have no option other than running ./init again and input your current blog information to generate a new template file."
	echo "Once you fixed this crap, DON'T delete anything that's part of nci system. Good luck."
	exit 1
fi

python3 refresh.py
